using System;
using System.Runtime.Serialization;
namespace Net35.Xrm.Sdk.Query
{
	[DataContract(Name = "FilterExpression", Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts")]
	public sealed class FilterExpression : IExtensibleDataObject
	{
		private LogicalOperator _filterOperator;
		private DataCollection<ConditionExpression> _conditions;
		private DataCollection<FilterExpression> _filters;
		private bool _isQuickFindFilter;
		private ExtensionDataObject _extensionDataObject;
		[DataMember]
		public LogicalOperator FilterOperator
		{
			get
			{
				return this._filterOperator;
			}
			set
			{
				this._filterOperator = value;
			}
		}
		[DataMember]
		public DataCollection<ConditionExpression> Conditions
		{
			get
			{
				if (this._conditions == null)
				{
					this._conditions = new DataCollection<ConditionExpression>();
				}
				return this._conditions;
			}
			private set
			{
				this._conditions = value;
			}
		}
		[DataMember]
		public DataCollection<FilterExpression> Filters
		{
			get
			{
				if (this._filters == null)
				{
					this._filters = new DataCollection<FilterExpression>();
				}
				return this._filters;
			}
			private set
			{
				this._filters = value;
			}
		}
		[DataMember(Order = 51, EmitDefaultValue = false)]
		public bool IsQuickFindFilter
		{
			get
			{
				return this._isQuickFindFilter;
			}
			set
			{
				this._isQuickFindFilter = value;
			}
		}
		public ExtensionDataObject ExtensionData
		{
			get
			{
				return this._extensionDataObject;
			}
			set
			{
				this._extensionDataObject = value;
			}
		}
		public FilterExpression()
		{
		}
		public FilterExpression(LogicalOperator filterOperator)
		{
			this.FilterOperator = filterOperator;
		}
		public void AddCondition(string attributeName, ConditionOperator conditionOperator, params object[] values)
		{
			this.Conditions.Add(new ConditionExpression(attributeName, conditionOperator, values));
		}
		public void AddCondition(string entityName, string attributeName, ConditionOperator conditionOperator, params object[] values)
		{
			this.Conditions.Add(new ConditionExpression(entityName, attributeName, conditionOperator, values));
		}
		public void AddCondition(ConditionExpression condition)
		{
			this.Conditions.Add(condition);
		}
		public FilterExpression AddFilter(LogicalOperator logicalOperator)
		{
			FilterExpression filterExpression = new FilterExpression();
			filterExpression.FilterOperator = logicalOperator;
			this.Filters.Add(filterExpression);
			return filterExpression;
		}
		public void AddFilter(FilterExpression childFilter)
		{
			if (childFilter != null)
			{
				this.Filters.Add(childFilter);
			}
		}
		internal void Accept(IQueryVisitor visitor)
		{
			visitor.Visit(this);
		}
	}
}
